<?php
use yii\helpers\Html;
use yii\helpers\Url;
/* @var $this yii\web\View */
$this->title = '个人账户';
?>
<section id="body_h" class='bcolor-eb'>
		<div class="modular4">
			<img width="100%" src="<?= Yii::getAlias('@web') . '/' ?>images/myself-top.jpg" alt="我的账户">
			<div class="modular4-con">
				<p class="modular4-con8">
					<span>
						<a href="javascript:;"><img width="100%" src="<?= Yii::getAlias('@web') . '/' ?>images/myself-header.jpg" alt="头像"></a>
					    <input type="file" name="upfile" id="fileField" />
					</span>
				</p>
				<p class="modular4-con9"><em><?= $userinfos['username'];?></em><a href="<?= Url::to(['site/logout']);?>">[登出]</a></p>
				<p class="modular4-con10">我的余额：￥<?= number_format($userinfos['userable']+$userinfos['frozen']+$userinfos['uncollected'],2);?></p>
				<p class="modular4-con11">冻结金额：￥<?= number_format($userinfos['frozen'],2);?></p>
				<p class="modular4-con12">待收总额：￥<?= number_format($userinfos['uncollected'],2);?></p>
				<p class="modular4-con13"><span>待收利息：￥<?= number_format($userinfos['interest'],2);?></span><a href="<?= Url::to(['site/accountdetail']);?>">查看待收详情</a></p>
				<p class='clearfix modular4-con14'>
					<a class="float-left deepy-f" href="recharge.html">充值</a>
					<a class="float-right y-f" href="withdrawals.html">提现</a>
				</p>
				<p class='modular4-con15'><a href="<?= Url::to(['site/setting']);?>">设置</a></p>
			</div>
		</div>
	<div class="wh-container">
		<div class="modular5">
			<ul class="mould-1 clearfix">
				<li data-cato="mould-2list1" data-url="moneyrecord/moneylist" class='current'><a href="/">资金记录</a></li>
				<li data-cato="mould-2list2" data-url="moneyrecord/rechargelist"><a href="/">充值记录</a></li>
				<li data-cato="mould-2list3" data-url="moneyrecord/withdrawlist"><a href="/">提现记录</a></li>
			</ul>
			<!--以下为循环的选项卡得内容部分-->
			<div id="mould-2list1" class="modular5-con hide">
				<table class="tablelist">
					<tr class="modular5-conttit">
						<td class="modular5-con1h">时间</td>
						<td class="modular5-con1h">类型</td>
						<td class="modular5-con1h">&nbsp;&nbsp;&nbsp;金额&nbsp;&nbsp;&nbsp;</td>
						<td class="modular5-con1h">说明</td>
					</tr>
				<?php if ($moneylist){foreach ($moneylist as $K1=>$V1){?>
					<tr>
						<td class="modular5-con1h"><?= substr($V1['time'], 0,10);?></td>
						<td class="modular5-con1h"><?= $V1['type'];?></td>
						<td class="modular5-con1h">￥<?= number_format($V1['money'],2);?></td>
						<td><p class="text-l modular5-contit"><?= $V1['info'];?></p></td>
					</tr>	
				<?php }}?>			
				</table>
			</div>
			<div id="mould-2list2" class="modular5-con hide">
				<table class="tablelist">
					<tr class="modular5-conttit">
						<td class="modular5-con1h">时间</td>
						<td class="modular5-con1h">类型</td>
						<td class="modular5-con1h">&nbsp;&nbsp;&nbsp;金额&nbsp;&nbsp;&nbsp;</td>
						<td class="modular5-con1h">状态</td>
					</tr>
					<tr>
						<td class="modular5-con1h">2015-10-16</td>
						<td class="modular5-con1h">线下</td>
						<td class="modular5-con1h">￥23</td>
						<td class="modular5-con1h">成功</td>
					</tr>
					
				</table>
			</div>
			<div id="mould-2list3" class="modular5-con hide">
				<table class="tablelist">
					<tr class="modular5-conttit">
						<td class="modular5-con1h">时间</td>
						<td class="modular5-con1h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;金额&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
						<td class="modular5-con1h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;状态&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
					</tr>
					<tr>
						<td class="modular5-con1h">2015-10-16</td>
						<td class="modular5-con1h">￥23,000</td>
						<td class="modular5-con1h">成功</td>
					</tr>
								
				</table>
			</div>
		</div>
	</div>
		<div class="footer-h"></div>
	</section>
	<section id="footer">
		<ul class="footer-nav clearfix">
		    <li class="current-bot">
		        <a href="<?= Url::to('main');?>">
		            <img src="<?= Yii::getAlias('@web') . '/' ?>images/footer1-on.png" alt="">
		            首页
		        </a>
		    </li>
		    <li>
		        <a href="<?= Url::to('member');?>">
		            <img src="<?= Yii::getAlias('@web') . '/' ?>images/footer2.png" alt="">
		            我的账户
		        </a>
		    </li>
		    <li>
		        <a href="<?= Url::to(['company/about']);?>">
		            <img src="<?= Yii::getAlias('@web') . '/' ?>images/footer3.png" alt="">
		            关于我们
		        </a>
		    </li>
		</ul>
	</section>
<script src="<?= Yii::getAlias('@web') . '/' ?>js/reset.js"></script>
	<script>
	$(function($) {
	    var UA=window.navigator.userAgent;  //使用设备
	    var CLICK="click";
	    if(/ipad|iphone|android/.test(UA)){   //判断使用设备
	        CLICK="tap";
	    }
	    var id='mould-2list1';
		var url = 'moneyrecord/moneylist';
        var page=1;//当前页
        var ul_obj = $('#'+id+' .tablelist'); //数据加载的位置
	    var catoFram=$(".modular5-con");
	    var subNav=$(".mould-1 li");
	    $("#mould-2list1").removeClass("hide");
	    subNav[0].className += " current" ;
	    subNav[CLICK](function(event){
            event.preventDefault();
	        var _this=$(this);
	        page = 1;
	        id=_this.data("cato"); 
	        var cur=$("#"+id);
			url = _this.data("url");
			ul_obj = $('#'+id+' .tablelist'); //数据加载的位置
	        subNav.removeClass("current");
	        _this.addClass("current");
	        catoFram.addClass("hide");
	        cur.scrollTop(0);        
	        cur.removeClass("hide");
	        $.ajax({
                type: 'GET',
                url: '../'+url+'?page='+page+'&num=7&sKey='+'<?= $sKey;?>',
                dataType: 'text',
                success: function(json){
					var dataObj=eval("("+json+")");
			        ul_obj.find("tr").remove();	//移除列表内容
			        if(url=='moneyrecord/moneylist')
			        {
						var temp = '<tr class="modular5-conttit"><td class="modular5-con1h">时间</td><td class="modular5-con1h">类型</td><td class="modular5-con1h">&nbsp;&nbsp;&nbsp;金额&nbsp;&nbsp;&nbsp;</td><td class="modular5-con1h">说明</td></tr>';
				    }
			        else if(url=='moneyrecord/rechargelist')
			        {
			        	var temp = '<tr class="modular5-conttit"><td class="modular5-con1h">时间</td><td class="modular5-con1h">类型</td><td class="modular5-con1h">&nbsp;&nbsp;&nbsp;金额&nbsp;&nbsp;&nbsp;</td><td class="modular5-con1h">状态</td></tr>';
				    }
			        else if(url=='moneyrecord/withdrawlist')
			        {
						var temp = '<tr class="modular5-conttit"><td class="modular5-con1h">时间</td><td class="modular5-con1h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;金额&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td><td class="modular5-con1h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;状态&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td></tr>';
				    }
			        ul_obj.append(temp);
			        if(url=='moneyrecord/moneylist')
			        {
			        	$.each(dataObj.list,function(i,val){
							ul_obj.append('<tr><td class="modular5-con1h">'+val.time.substr(0,10)+'</td><td class="modular5-con1h">'+val.type+'</td><td class="modular5-con1h">￥'+fmoney(val.money)+'</td><td><p class="text-l modular5-contit">'+val.info+'</p></td></tr>');
						});
				    }
			        else if(url=='moneyrecord/rechargelist')
			        {
				        var type;
				        var status;
			        	$.each(dataObj.list,function(i,val){
				        	if(val.status==0){status='失败';}else if(val.status==1){status='成功';}else if(val.status==2){status='待处理';}
				        	if(val.type==0){type='线下';}else if(val.type==1){type='宝付';}else if(val.type==2){type='其他';}
			        		ul_obj.append('<tr><td class="modular5-con1h">'+val.time.substr(0,10)+'</td><td class="modular5-con1h">'+type+'</td><td class="modular5-con1h">￥'+fmoney(val.money)+'</td><td><p class="text-l modular5-contit">'+status+'</p></td></tr>');
						});
				    }
			        else if(url=='moneyrecord/withdrawlist')
			        {
			        	var status;
			        	$.each(dataObj.list,function(i,val){
				        	if(val.status==0){status='失败';}else if(val.status==1){status='成功';}else if(val.status==2){status='待处理';}
							ul_obj.append('<tr><td class="modular5-con1h">'+val.time.substr(0,10)+'</td><td class="modular5-con1h">￥'+fmoney(val.money)+'</td><td class="modular5-con1h">'+status+'</td></tr>');
						});
				    }
                    $(".loading").remove();//删除加载图片
                    ajax=!1;//注明已经完成ajax加载
                },
                error: function(xhr, type){
                    $(".loading").html("暂无内容！");
                }
            });
            $(".bodyA").hide();
	    });
	  //需要 zepto.js支持
        var ajax=!1;//是否加载中
        Zepto(function($){
            $(window).scroll(function(){
                if(($(window).scrollTop() + $(window).height() > $(document).height()-40) && !ajax){
                    //滚动条拉到离底40像素内，而且没ajax中，而且没超过总页数
					
                    page++;//当前页增加1
                    ajax=!0;//注明开始ajax加载中
                    $(".wh-container").append('<div class="loading" style="text-align:center;  font-size:16px; color:#999; "><img  style="vertical-align: middle; margin-right:10px;" src="<?= yii::getAlias('@web').'/' ?>images/loading1.gif" alt="" />上拉加载</div> ');//出现加载图片
					
                    $.ajax({
                        type: 'GET',
                        url: '../'+url+'?page='+page+'&num=7&sKey='+'<?= $sKey;?>',
                        dataType: 'text',
                        success: function(json){
							var dataObj=eval("("+json+")");
							if(dataObj.list)
							{
								if(url=='moneyrecord/moneylist')
						        {
						        	$.each(dataObj.list,function(i,val){
										ul_obj.append('<tr><td class="modular5-con1h">'+val.time.substr(0,10)+'</td><td class="modular5-con1h">'+val.type+'</td><td class="modular5-con1h">￥'+fmoney(val.money)+'</td><td><p class="text-l modular5-contit">'+val.info+'</p></td></tr>');
									});
							    }
						        else if(url=='moneyrecord/rechargelist')
						        {
							        var type;
							        var status;
						        	$.each(dataObj.list,function(i,val){
							        	if(val.status==0){status='失败';}else if(val.status==1){status='成功';}else if(val.status==2){status='待处理';}
							        	if(val.type==0){type='线下';}else if(val.type==1){type='宝付';}else if(val.type==2){type='其他';}
						        		ul_obj.append('<tr><td class="modular5-con1h">'+val.time.substr(0,10)+'</td><td class="modular5-con1h">'+type+'</td><td class="modular5-con1h">￥'+fmoney(val.money)+'</td><td><p class="text-l modular5-contit">'+status+'</p></td></tr>');
									});
							    }
						        else if(url=='moneyrecord/withdrawlist')
						        {
						        	var status;
						        	$.each(dataObj.list,function(i,val){
							        	if(val.status==0){status='失败';}else if(val.status==1){status='成功';}else if(val.status==2){status='待处理';}
										ul_obj.append('<tr><td class="modular5-con1h">'+val.time.substr(0,10)+'</td><td class="modular5-con1h">￥'+fmoney(val.money)+'</td><td class="modular5-con1h">'+status+'</td></tr>');
									});
							    }
	                            
	                            $(".loading").remove();//删除加载图片
	                            ajax=!1;//注明已经完成ajax加载
							}
							else if(dataObj.msg=='sKey已失效！')
							{
								$(".loading").remove();//删除加载图片
								location.href='<?= Url::to(['site/signin']);?>';
							}
							else
							{
								$(".loading").html("暂无内容！");
	                            ajax=!0;
							}
                        },
                        error: function(xhr, type){
                            $(".loading").html("暂无内容！");
                            ajax=!0;
                        }
                    });
                }
            });
        });
		$(".bodyA").hide();
	});
	function fmoney(strNum) {
		if (strNum.length <= 3) {
		return strNum;
		}
		if (!/^(\+|-)?(\d+)(\.\d+)?$/.test(strNum)) {
		return strNum;
		}
		var a = RegExp.$1, b = RegExp.$2, c = RegExp.$3;
		var re = new RegExp();
		re.compile("(\\d)(\\d{3})(,|$)");
		while (re.test(b)) {
		b = b.replace(re, "$1,$2$3");
		}
		return a + "" + b + "" + c;
		}
</script>
<script src='<?= Yii::getAlias('@web') . '/' ?>js/zepto.min.js'></script>